﻿// JScript File


        
// set upload control
function addFile(name, id){
    var fList = document.getElementById("divFiles");
                
    if(fList!=null){
        fList.className = "files";
        fList.innerHTML = fList.innerHTML + "<div id='" + id + "'>" + name + " <a class=blue href=\"javascript:removeFile('"+ id +"');\">Remove</a></div>";
        fileCount++;
    }
}
function removeFile(id){
    var fList = document.getElementById("divFiles");
    var d = document.getElementById(id);
    
    if(confirm("Are you sure to remove the file?")){
        if(fList!=null && d!=null){
            //alert("d: \nsid: \npid:");
            remove(d, sid, pid);
            fList.removeChild(d);
            
            // check if there is child
            fileCount--;
            if(!fList.hasChildNodes() || fileCount==0){
                fList.className = "hidden";
            }
        }                                
    }
}

function showCtrl()
{
	var ctrl = document.getElementById("divCtrl");
	var bt = document.getElementById("divAddFile");
	
	if(ctrl!=null){
		ctrl.className = "";
	}
	if(bt!=null){
		bt.className = "hidden";
	}
}

function hideCtrl()
{
    var ctrl = document.getElementById("divCtrl");
                
    if(ctrl!=null){
        ctrl.className = "hidden";
    }
}

function showStatus(){
    var stat = document.getElementById("divStat");
                
    if(stat!=null){                
        stat.className = "";
        //alert(fraUpload.document.frmUpload.file1.value);
        stat.innerHTML = "<b>Uploading...</b> \"" + fraUpload.document.frmUpload.file1.value + "\"";
    }
}
function reset(){
    var stat = document.getElementById("divStat");
    var bt = document.getElementById("divAddFile");            
    
    if(stat!=null){
        stat.className = "hidden";
        stat.innerHTML = "";
    }
    if(bt!=null){
        bt.className = "";
    }
}